﻿#include "record.h"
#include "ui_record.h"
#include <QDebug>
#include <QDateTime>
#include <QString>
#include "userDataFormate.h"
#include <QCheckBox>
#include <QDateTime>
#include "cdatabaseinterface.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QDebug>
#pragma execution_character_set("utf-8")
Record::Record(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Record),
    m_perPageCount(8),
    m_trainTableCurrentPage(1),
    m_evaluateTableCurrentPage(1),
    m_trainRecordTotalPage(1),
    m_evaluateRecordTotalPage(1),
    trainReport(NULL),
    evaluateReport(NULL),
    m_reportCompared(NULL)
{
    ui->setupUi(this);

    initWidget();
    ui->stackedWidget->setCurrentIndex(0);
    initTrainRecordTable();
    initEvaluateRecordTable();
    this->setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint);
    ui->stackedWidget->setCurrentIndex(0);

    trainReport = new TrainingReport();
    evaluateReport = new evaluationReport();
    m_deleteRepoet = new DeleteReport();
    m_reportCompared = new ReportCompared();

}

Record::~Record()
{
    if(m_deleteRepoet)
        delete m_deleteRepoet;
    if(m_reportCompared)
        delete m_reportCompared;
    delete ui;
}
//初始化控件
void Record::initWidget()
{
    ui->evaluateFrontPage_btn->setStyleSheet("border-image: url(:/icon/frontPage.png);");
    ui->trainFrontPage_btn->setStyleSheet("border-image: url(:/icon/frontPage.png);");

    ui->evaluateBackPage_btn->setStyleSheet("border-image: url(:/icon/backPage.png);");
    ui->trainBackPage_btn->setStyleSheet("border-image: url(:/icon/backPage.png);");
}
//初始化训练表格
void Record::initTrainRecordTable()
{
    ui->trainRecord_tablewidget->setColumnCount(9);//设置列数
    ui->trainRecord_tablewidget->setRowCount(m_perPageCount);//设置行数
    ui->trainRecord_tablewidget->setShowGrid(false);

    //设置表头里面的内容
    ui->trainRecord_tablewidget->setColumnWidth(0,100);
    ui->trainRecord_tablewidget->setColumnWidth(1,300);
    ui->trainRecord_tablewidget->setColumnWidth(2,220);
    ui->trainRecord_tablewidget->setColumnWidth(3,200);
    ui->trainRecord_tablewidget->setColumnWidth(4,140);
    ui->trainRecord_tablewidget->setColumnWidth(5,180);
    ui->trainRecord_tablewidget->setColumnWidth(6,180);
    ui->trainRecord_tablewidget->setColumnWidth(7,190);
    ui->trainRecord_tablewidget->setColumnWidth(8,191);



    ui->trainRecord_tablewidget->verticalHeader()->setDefaultSectionSize(72);
    //设置行高
    for(int i = 0;i < m_perPageCount;i++)
        ui->trainRecord_tablewidget->setRowHeight(i,72);

    ui->trainRecord_tablewidget->setAlternatingRowColors(true);
    ui->trainRecord_tablewidget->setPalette(QPalette(Qt::lightGray));
    //设置无边框
    ui->trainRecord_tablewidget->setShowGrid(false);

    //在默认情况下，表格里的字符是可以更改的，这样设置只读。禁止用户修改
    ui->trainRecord_tablewidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
    //设置整行选中
    ui->trainRecord_tablewidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    //隐藏列表头
    ui->trainRecord_tablewidget->verticalHeader()->setVisible(false);
    //隐藏行表头
    ui->trainRecord_tablewidget->horizontalHeader()->setVisible(false);

    connect(ui->trainRecord_tablewidget,&QTableWidget::cellClicked,this,&Record::slotTrainingCellWidgetClicked);


}

//初始化评估表
void Record::initEvaluateRecordTable()
{
    //设置表格列数
    ui->evaluateRecord_tableWidget->setColumnCount(7);
    //设置表格行数
    ui->evaluateRecord_tableWidget->setRowCount(8);


    //设置列宽
    ui->evaluateRecord_tableWidget->setColumnWidth(0,100);
    ui->evaluateRecord_tableWidget->setColumnWidth(1,270);
    ui->evaluateRecord_tableWidget->setColumnWidth(2,266);
    ui->evaluateRecord_tableWidget->setColumnWidth(3,180);
    ui->evaluateRecord_tableWidget->setColumnWidth(4,460);
    ui->evaluateRecord_tableWidget->setColumnWidth(5,212);
    ui->evaluateRecord_tableWidget->setColumnWidth(6,213);

    ui->evaluateRecord_tableWidget->verticalHeader()->setDefaultSectionSize(72);
    //设置行高
    for(int i = 0;i < 8;i++)

        ui->evaluateRecord_tableWidget->setRowHeight(i,72);

    ui->evaluateRecord_tableWidget->setAlternatingRowColors(true);
    ui->evaluateRecord_tableWidget->setPalette(QPalette(Qt::lightGray));

    ui->evaluateRecord_tableWidget->setShowGrid(false);

    //在默认情况下，表格里的字符是可以更改的，这样设置只读。禁止用户修改
    ui->evaluateRecord_tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
    //设置整行选中
    ui->evaluateRecord_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    //隐藏列表头
    ui->evaluateRecord_tableWidget->verticalHeader()->setVisible(false);
    //隐藏行表头
    ui->evaluateRecord_tableWidget->horizontalHeader()->setVisible(false);

    connect(ui->evaluateRecord_tableWidget,&QTableWidget::cellClicked,this,&Record::slotEvaluateCellWidgetClicked);

}

void Record::updateTrainBottomSetting(int num)
{

}

//填充训练表
void Record::fillTrainTable(int pageIndex)
{
    ui->trainRecord_tablewidget->clearContents();
    ST_PatientMsg st_PatientMsg;
    st_PatientMsg = CurrentUserData::getInstace()->getCurrentPatientMsg();
    QString query(QString("select * from TrainRecord where ID = '%1' order by trainingDate DESC").arg(st_PatientMsg.ID));
    CDatabaseInterface *dataBase = CDatabaseInterface::getInstance();
    if(dataBase->exec(query))
    {
        int count = CDatabaseInterface::getInstance()->getValuesSize();
        //总页数
        int displayPage = count/m_perPageCount;
        //如果不可以整除则加1
        if(count%m_perPageCount)
            displayPage += 1;
        m_trainRecordTotalPage = displayPage;
        //当前页要显示的条数
        int displayCount = 0;
        //满额显示
        if(pageIndex < displayPage)
        {
            displayCount = m_perPageCount;
        }
        else if(pageIndex == displayPage)
        {
            displayCount = count - (pageIndex-1)*m_perPageCount;
        }
        else
        {
            return;
        }

        trainingDisplayCount = displayCount;

        if(trainingDisplayCount <= 0)
            return;
        ui->trainIndexPage_label->setText(QString::number(pageIndex)+"/"+QString::number(m_trainRecordTotalPage)+"页");
        trainVariantMap.clear();
        QList<QVariantMap> variantMap = CDatabaseInterface::getInstance()->getValues((pageIndex-1)*m_perPageCount,displayCount);
        trainVariantMap = variantMap;


        for(int i = 0;i < variantMap.size();i++)
        {
            //第0列checkBox
            QTableWidgetItem *checkItem = new QTableWidgetItem();
            ui->trainRecord_tablewidget->setItem(i,0,checkItem);
            QCheckBox *checkBox = new QCheckBox();
            checkBox->setFixedWidth(40);
            checkBox->setLayoutDirection(Qt::RightToLeft);
            ui->trainRecord_tablewidget->setCellWidget(i,0,checkBox);
            //查看按钮
            QLabel *checkLabel = new QLabel();
            checkLabel->setPixmap(QPixmap(":/icon/check.png"));
            checkLabel->setAlignment(Qt::AlignCenter);
            ui->trainRecord_tablewidget->setCellWidget(i,7,checkLabel);

            //删除按钮
            QLabel *deletelabel = new QLabel();
            deletelabel->setPixmap(QPixmap(":/icon/delete.png"));
            deletelabel->setAlignment(Qt::AlignCenter);
            ui->trainRecord_tablewidget->setCellWidget(i,8,deletelabel);


            ST_TrainRecord st_trainRecord = variantMapToTrainRecord(variantMap.at(i));
            //训练日期
            ui->trainRecord_tablewidget->setItem(i,1,new QTableWidgetItem());
            ui->trainRecord_tablewidget->item(i,1)->setTextAlignment(Qt::AlignCenter);
            ui->trainRecord_tablewidget->item(i,1)->setText(st_trainRecord.trainingDate.toString("yyyy-MM-dd hh:mm:ss"));
            //训练时长
            ui->trainRecord_tablewidget->setItem(i,2,new QTableWidgetItem());
            ui->trainRecord_tablewidget->item(i,2)->setTextAlignment(Qt::AlignCenter);
            int min = st_trainRecord.trainingDuration/60;
            int sec = st_trainRecord.trainingDuration%60;
            ui->trainRecord_tablewidget->item(i,2)->setText(QString("%1 min  %2 s").arg(min).arg(sec));

            //阻力
            ui->trainRecord_tablewidget->setItem(i,3,new QTableWidgetItem());
            ui->trainRecord_tablewidget->item(i,3)->setTextAlignment(Qt::AlignCenter);
            ui->trainRecord_tablewidget->item(i,3)->setText(QString::number(st_trainRecord.resistance));
            //难度
            ui->trainRecord_tablewidget->setItem(i,4,new QTableWidgetItem());
            ui->trainRecord_tablewidget->item(i,4)->setTextAlignment(Qt::AlignCenter);
            ui->trainRecord_tablewidget->item(i,4)->setText(st_trainRecord.difficulty);
            //得分
            ui->trainRecord_tablewidget->setItem(i,5,new QTableWidgetItem());
            ui->trainRecord_tablewidget->item(i,5)->setTextAlignment(Qt::AlignCenter);
            ui->trainRecord_tablewidget->item(i,5)->setText(QString::number(st_trainRecord.score));
            //游戏方式
            ui->trainRecord_tablewidget->setItem(i,6,new QTableWidgetItem());
            ui->trainRecord_tablewidget->item(i,6)->setTextAlignment(Qt::AlignCenter);
            ui->trainRecord_tablewidget->item(i,6)->setText(st_trainRecord.gameplay);
        }
    }
    else
    {
        qDebug()<<dataBase->getLastError();
    }
}

//填充评估表
void Record::fillEvaluateTable(int pageIndex)
{

    ui->evaluateRecord_tableWidget->clearContents();
    ST_PatientMsg st_PatientMsg;
    st_PatientMsg = CurrentUserData::getInstace()->getCurrentPatientMsg();
    QString query(QString("select * from EvaluateRecord where ID = '%1' order by evaluateDate DESC").arg(st_PatientMsg.ID));
    CDatabaseInterface *dataBase = CDatabaseInterface::getInstance();
    if(dataBase->exec(query))
    {

        int count = CDatabaseInterface::getInstance()->getValuesSize();

        //总页数
        int displayPage = count/m_perPageCount;

        //如果不可以整除则加1
        if(count%m_perPageCount)
            displayPage += 1;

        m_evaluateRecordTotalPage = displayPage;
        //当前页要显示的条数
        int displayCount = 0;

        //满额显示
        if(pageIndex < displayPage)
        {
            displayCount = m_perPageCount;
        }
        else if(pageIndex == displayPage)
        {
            displayCount = count - (pageIndex-1)*m_perPageCount;
        }
        else
        {
            return;
        }
        //当前页要显示条数
        evaluateDisplayCount = displayCount;

        //设置页数
        if(evaluateDisplayCount <= 0)
            return;
        ui->evaluateIndexPage_label->setText(QString::number(pageIndex)+"/"+QString::number(m_evaluateRecordTotalPage)+"页");
        evaluateVariantMap.clear();
        QList<QVariantMap> variantMap = CDatabaseInterface::getInstance()->getValues((pageIndex-1)*m_perPageCount,displayCount);
        evaluateVariantMap = variantMap;


        for(int i = 0;i < variantMap.size();i++)
        {
            //第0列checkBox
            QTableWidgetItem *checkItem = new QTableWidgetItem();
            ui->evaluateRecord_tableWidget->setItem(i,0,checkItem);
            QCheckBox *checkBox = new QCheckBox();
            checkBox->setFixedWidth(40);
            checkBox->setLayoutDirection(Qt::RightToLeft);
            ui->evaluateRecord_tableWidget->setCellWidget(i,0,checkBox);

            //查看按钮
            QLabel *checkLabel = new QLabel();
            checkLabel->setPixmap(QPixmap(":/icon/check.png"));
            checkLabel->setAlignment(Qt::AlignCenter);
            ui->evaluateRecord_tableWidget->setCellWidget(i,5,checkLabel);

            //删除按钮
            QLabel *deletelabel = new QLabel();
            deletelabel->setPixmap(QPixmap(":/icon/delete.png"));
            deletelabel->setAlignment(Qt::AlignCenter);
            ui->evaluateRecord_tableWidget->setCellWidget(i,6,deletelabel);

            //填充表格内容
            ST_EvaluateRecord st_evaluateRecord = variantMapToEvaluateRecord(variantMap.at(i));
            //评估日期
            ui->evaluateRecord_tableWidget->setItem(i,1,new QTableWidgetItem());
            ui->evaluateRecord_tableWidget->item(i,1)->setTextAlignment(Qt::AlignCenter);
            ui->evaluateRecord_tableWidget->item(i,1)->setText(st_evaluateRecord.evaluateDate.toString("yyyy-MM-dd hh:mm:ss"));
            qDebug()<<st_evaluateRecord.evaluateDate;

            //评估时长
            ui->evaluateRecord_tableWidget->setItem(i,2,new QTableWidgetItem());
            ui->evaluateRecord_tableWidget->item(i,2)->setTextAlignment(Qt::AlignCenter);
            int min = st_evaluateRecord.evaluateDuration/60;

            int sec = st_evaluateRecord.evaluateDuration%60;
            ui->evaluateRecord_tableWidget->item(i,2)->setText(QString("%1 min  %2 s").arg(min).arg(sec));
            //阻力
            ui->evaluateRecord_tableWidget->setItem(i,3,new QTableWidgetItem());
            ui->evaluateRecord_tableWidget->item(i,3)->setTextAlignment(Qt::AlignCenter);
            ui->evaluateRecord_tableWidget->item(i,3)->setText(QString::number(st_evaluateRecord.resistance));

            //最大角度
            ui->evaluateRecord_tableWidget->setItem(i,4,new QTableWidgetItem());
            ui->evaluateRecord_tableWidget->item(i,4)->setTextAlignment(Qt::AlignCenter);
            ui->evaluateRecord_tableWidget->item(i,4)->setText(st_evaluateRecord.maxAngle);

        }
    }
    else
    {
        qDebug()<<dataBase->getLastError();
    }
}

void Record::on_evaluateRecord_Btn_clicked()
{
    ui->stackedWidget->setCurrentIndex(0);
    ui->evaluateRecord_Btn->setStyleSheet("background: #0D9DDB;border-radius: 4px;color:white;");
    ui->trainRecord_Btn->setStyleSheet("background: #EFEFEF;border-radius: 4px;color:#333333;");
}


void Record::on_trainRecord_Btn_clicked()
{
    ui->stackedWidget->setCurrentIndex(1);
    ui->trainRecord_Btn->setStyleSheet("background: #0D9DDB;border-radius: 4px;color:white;");
    ui->evaluateRecord_Btn->setStyleSheet("background: #EFEFEF;border-radius: 4px;color:#333333;");
}
void Record::slotEvaluateCellWidgetClicked(int row, int column)
{
    if(row >= evaluateDisplayCount )
        return;
    QString evaluateDate = ui->evaluateRecord_tableWidget->item(row,1)->data(Qt::DisplayRole).toString();
    switch(column)
    {
    case 5: //查看
    {
        ST_EvaluateReport st_evaluateReport  = evaluateReport->getReportDataByStartTime(evaluateDate);
        QList<QPointF> pointList;
        evaluateReport->setReportData(st_evaluateReport,2,pointList);

    }
        break;
    case 6: //删除
        //删除记录条目
        m_deleteRepoet->show();
        m_deleteRepoet->exec();
        if(m_deleteRepoet->isDeletedReport()){
            QString table("EvaluateRecord");
            if(!CDatabaseInterface::getInstance()->deleteRowTable(table,"evaluateDateStr",evaluateDate))
                qDebug()<<CDatabaseInterface::getInstance()->getLastError();
            else
            {
                --evaluateDisplayCount;
                //当前页已经无条目显示，则向前翻页
                if(evaluateDisplayCount <= 0)
                {
                    m_evaluateTableCurrentPage--;
                    if(m_evaluateTableCurrentPage  < 1)
                    {
                        m_evaluateTableCurrentPage = 1;

                    }
                }
                fillEvaluateTable(m_evaluateTableCurrentPage);
                break;
            }
        }
    }
}

void Record::slotTrainingCellWidgetClicked(int row, int column)
{
    if(row >= trainingDisplayCount )
        return;
    QString trainingDate = ui->trainRecord_tablewidget->item(row,1)->data(Qt::DisplayRole).toString();
    switch(column)
    {
    case 7: //查看
    {
        ST_TrainReport st_trainReport  = trainReport->getReportDataByStartTime(trainingDate);
        QList<QPointF> pointList;
        trainReport->setReportData(st_trainReport,2,pointList);

    }
        break;
    case 8: //删除
        //删除记录条目
        m_deleteRepoet->show();
        m_deleteRepoet->exec();
        if(m_deleteRepoet->isDeletedReport())
        {
            QString table("TrainRecord");
            if(!CDatabaseInterface::getInstance()->deleteRowTable(table,"trainingDateStr",trainingDate))
                qDebug()<<CDatabaseInterface::getInstance()->getLastError();
            else
            {
                --trainingDisplayCount;
                //当前页已经无条目显示，则向前翻页
                if(trainingDisplayCount <= 0)
                {
                    m_trainTableCurrentPage--;
                    if(m_trainTableCurrentPage  < 1)
                    {
                        m_trainTableCurrentPage = 1;

                    }
                }
                fillTrainTable(m_trainTableCurrentPage);
                break;
            }
        }


    }
}


void Record::on_evaluateFrontPage_btn_clicked()
{
    m_evaluateTableCurrentPage--;
    if(m_evaluateTableCurrentPage < 1)
    {
        m_evaluateTableCurrentPage = 1;
        return;
    }
    fillEvaluateTable(m_evaluateTableCurrentPage);
}

void Record::on_evaluateBackPage_btn_clicked()
{
    m_evaluateTableCurrentPage++;
    if(m_evaluateTableCurrentPage > m_evaluateRecordTotalPage)
        m_evaluateTableCurrentPage = m_evaluateRecordTotalPage;


    fillEvaluateTable(m_evaluateTableCurrentPage);
}

void Record::on_evaluateGo_btn_clicked()
{
    int destPage = ui->evaluateDestPage_lineEdit->text().toUInt();
    if(destPage > 0 && destPage <= m_evaluateRecordTotalPage)
    {
        m_evaluateTableCurrentPage = destPage;
        fillEvaluateTable(destPage);
    }
}

void Record::on_trainFrontPage_btn_clicked()
{
    m_trainTableCurrentPage--;
    if(m_trainTableCurrentPage  < 1)
    {
        m_trainTableCurrentPage = 1;
        return;
    }
    fillTrainTable(m_trainTableCurrentPage);
}

void Record::on_trainBackPage_btn_clicked()
{
    m_trainTableCurrentPage++;
    if(m_trainTableCurrentPage > m_trainRecordTotalPage)
        m_trainTableCurrentPage = m_trainRecordTotalPage;
    fillTrainTable(m_trainTableCurrentPage);
}

void Record::on_trainGo_btn_clicked()
{
    int destPage = ui->trainDestPage_lineEdit->text().toUInt();
    if(destPage > 0 && destPage <= m_trainRecordTotalPage)
    {
        m_trainTableCurrentPage = destPage;
        fillTrainTable(destPage);
    }
}

void Record::showEvent(QShowEvent *event)
{
    Q_UNUSED(event)
    fillTrainTable(1);
    fillEvaluateTable(1);
}

//训练全选
void Record::on_trainSelectAll_checkBox_toggled(bool checked)
{
    for(int i = 0;i < trainingDisplayCount;i++)
    {
        QCheckBox *checkBox = static_cast<QCheckBox*>(ui->trainRecord_tablewidget->cellWidget(i,0));
        checkBox->setChecked(checked);
    }
}

//训练删除选中项
void Record::on_trainDelete_btn_clicked()
{
    int deleteNum = 0;
    for(int i = 0;i <trainingDisplayCount;++i)
    {
        QCheckBox *checkBox = static_cast<QCheckBox*>(ui->trainRecord_tablewidget->cellWidget(i,0));

        if(checkBox->isChecked())
        {
            QString startTimeStr = ui->trainRecord_tablewidget->item(i,1)->data(Qt::DisplayRole).toString();
            if(!CDatabaseInterface::getInstance()->deleteRowTable("TrainRecord","trainingDateStr",startTimeStr))
                qDebug()<<"delete user failed"<<CDatabaseInterface::getInstance()->getLastError();
            else
                ++deleteNum;
        }
    }
    //减去删除的条数
    trainingDisplayCount-=deleteNum;
    if(trainingDisplayCount <= 0)
    {
        m_trainTableCurrentPage--;
        if(m_trainTableCurrentPage  < 1)
        {
            m_trainTableCurrentPage = 1;

        }
    }
    fillTrainTable(m_trainTableCurrentPage);
}



//评估删除选中项
void Record::on_evaluateDelete_btn_clicked()
{

    int deleteNum = 0;
    for(int i = 0;i <evaluateDisplayCount;++i)
    {
        QCheckBox *checkBox = static_cast<QCheckBox*>(ui->evaluateRecord_tableWidget->cellWidget(i,0));

        if(checkBox->isChecked())
        {
            QString startTimeStr = ui->evaluateRecord_tableWidget->item(i,1)->data(Qt::DisplayRole).toString();
            if(!CDatabaseInterface::getInstance()->deleteRowTable("EvaluateRecord","evaluateDateStr",startTimeStr))
                qDebug()<<"delete user failed"<<CDatabaseInterface::getInstance()->getLastError();
            else
                ++deleteNum;
        }
    }
    //减去删除的条数
    evaluateDisplayCount-=deleteNum;
    if(evaluateDisplayCount <= 0)
    {
        m_evaluateTableCurrentPage--;
        if(m_evaluateTableCurrentPage  < 1)
        {
            m_evaluateTableCurrentPage = 1;

        }
    }
    fillEvaluateTable(m_evaluateTableCurrentPage);
}



void Record::on_evaluateSelectAll_checkBox_toggled(bool checked)
{

    for(int i = 0;i < evaluateDisplayCount;i++)
    {
        QCheckBox *checkBox = static_cast<QCheckBox*>(ui->evaluateRecord_tableWidget->cellWidget(i,0));
        checkBox->setChecked(checked);
    }
}

void Record::on_trainVs_pushButton_clicked()
{

    int vsNum = 0;
       QList<int> selectList;
       for(int i = 0;i <trainingDisplayCount;++i)
       {
           QCheckBox *checkBox = static_cast<QCheckBox*>(ui->trainRecord_tablewidget->cellWidget(i,0));

           if(checkBox->isChecked())
           {
                ++vsNum;
               selectList.append(i);
           }

       }
       if(vsNum == 2)
       {
           QString trainingDate1 = ui->trainRecord_tablewidget->item(selectList.at(0),1)->data(Qt::DisplayRole).toString();
           ST_TrainReport st_trainReport1 = trainReport->getReportDataByStartTime(trainingDate1);
           QString trainingDate2 = ui->trainRecord_tablewidget->item(selectList.at(1),1)->data(Qt::DisplayRole).toString();
           ST_TrainReport st_trainReport2 = trainReport->getReportDataByStartTime(trainingDate2);
           //在对比界面中添加两个报告的数据就可以
           m_reportCompared->setVsTrainReportData(st_trainReport1,st_trainReport2);
       }
       else
       {
           QMessageBox::warning(NULL,tr("提示"),tr("请选择两项进行对比"));
       }
}

void Record::on_evaluationVs_pushButton_clicked()
{

    int vsNum = 0;
       QList<int> selectList;
       for(int i = 0;i <trainingDisplayCount;++i)
       {
           QCheckBox *checkBox = static_cast<QCheckBox*>(ui->evaluateRecord_tableWidget->cellWidget(i,0));

           if(checkBox->isChecked())
           {
                ++vsNum;
               selectList.append(i);
           }

       }
       if(vsNum == 2)
       {
           QString evaluateDate1 = ui->evaluateRecord_tableWidget->item(selectList.at(0),1)->data(Qt::DisplayRole).toString();
           ST_EvaluateReport st_evaluateReport1 = evaluateReport->getReportDataByStartTime(evaluateDate1);
           QString evaluateDate2 = ui->evaluateRecord_tableWidget->item(selectList.at(1),1)->data(Qt::DisplayRole).toString();
           ST_EvaluateReport st_evaluateReport2 = evaluateReport->getReportDataByStartTime(evaluateDate2);
           //在对比界面中添加两个报告的数据就可以
            m_reportCompared->setVsEvaluateReportData(st_evaluateReport1,st_evaluateReport2);
       }
       else
       {
           QMessageBox::warning(NULL,tr("提示"),tr("请选择两项进行对比"));
       }
}

void Record::changeEvent(QEvent* event)
{
    switch (event->type())
    {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        QWidget::changeEvent(event);
        break;
    }
}


